<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>SQE报表查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <meta content="0" http-equiv="Expires"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <link rel="stylesheet" href="../styles/base.css"/>
    <link rel="stylesheet" href="../styles/common.css"/>
    <link rel="stylesheet" href="../styles/font/iconfont.css"/>
    <link rel="stylesheet" href="../jqueryNicepage/css/layui.css"  media="all">
    <style>
        .body{
            background:#ddecf5;/*overflow: hidden;*/
        }
        tbody tr .td6{
             display: none;
         }
        #table2{
            margin-top: 20px;
            width:100%;
        }
        #table2 .layui-table{
            width:100%;
        }
        #table2 .layui-table tr{
            width:100%;

        }
        .layui-table td, .layui-table th{
            /*max-width: 50px;*/
            text-align: center;
        }

        .layui-table td input, .layui-table th input{
            text-align: center;
            width:100%;
        }
       /* .layui-table tr td:first-child,.layui-table tr th:first-child{
            max-width: 30px;
            width:30px;
        }*/
        .layui-table thead
        tbody tr .operationClick{
            display: none;
        }
        .searchContainer{
            position:relative;
            width:96%;
            margin-left: 2%;
            max-height: 96%;
            min-height: 96%;
           /* overflow-y: auto;*/
            margin-top: 10px;
        }
        .toExcell{
            margin: 10px;
            margin-left: 30px;
            float:right;
            background-color: #eee;
            font-family: 'Open Sans', sans-serif;
            font-size: 14px;
            text-decoration: none;
            font-weight: 600;
            color: #666;
            position: relative;
            padding: 5px 15px;
            margin-right: 15px;
            border-top-right-radius: 10px;
            border-bottom-right-radius: 10px;
            border-top-left-radius: 10px;
            border-bottom-left-radius: 10px;
            background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(242,242,242)), color-stop(1, rgb(242,242,242)) );
            cursor: pointer;
            overflow: hidden;
        }
        .toExcell:hover{
            color:#fff;
            background:#40E0D0;
        }
       #table2 .td0 a{
            color:#0000FF;
            cursor: pointer;
            text-decoration:underline;
        }
        .formContent{
            height:auto;
          /*  overflow-y: scroll;*/
        }
        .formContent center{
            margin-top:-20px;
        }
        .formContent center #pageBar2{
            position:absolute;
            bottom:10px;
            width:100%;
            text-align: center;
            display:none;
        }
        .layui-table[lay-size=sm] .td2{
            font-size: 12px;
            /*padding: 2px 2px;*/
            text-align: left;
        }
    </style>
</head>

<body class="body" style="">
<div id="loading">
    <img src='../styles/img/loading.gif' />
</div>
<div class="searchContainer">
    <div class="searchSureBtn toExcell">导出Excel</div>
    <div class="formContent">
    </div>

</center>
</div>
</body>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script src="../layer/layer.js" charset="utf-8"></script>
<script language="Javascript" src="../jqueryNicepage/js/layui.js"></script>
<script src="../js/common/utils.js"></script>
<script src="../js/common/myAjax.js"></script>
<script LANGUAGE="javascript">
    var widthList1=[];
   /* var heightform=$(".searchContainer").height()-$(".searchSureBtn").height()-20;
    $(".formContent").css("height",heightform*0.90);*/
    var height=document.body.clientHeight;
    var width =document.body.clientWidth;
    $("#loading img").css({
        "margin-left":width/2-25+"px",
        "margin-top":height/2-25+"px"
    })
    var num=getQueryStringByNameTwo("num")?getQueryStringByNameTwo("num"):"";
    var view=getQueryStringByNameTwo("view")?getQueryStringByNameTwo("view"):"";

   if(num==undefined||num==""){
       renderTable( window.json1);
       $(".toExcell").remove();
   }else{
       var url = "/sqe/sqeMaterial",
               data="view="+view+"&number="+encodeURIComponent(num);
       var heightx = document.body.clientHeight;
       var widthx = document.body.clientWidth;
       $("#loading img").css({
           "margin-left":( widthx / 2 - 25) + "px",
           "margin-top": (heightx / 2 - 25) + "px"
       })
       $("#loading").css({
           display:"block"
       });
       MaterialReverseAjax(url,data,suCallback);
       function suCallback(str){
           var check="false";
           var flage=true;
           //标准json格式 目前只支持[{a:b,c:d},{a:b,c:d}]此种格式
           var dataListObj=[];
           $("#loading").css({
               display:"none"
           });
           if(str.datalist!=undefined&&str.datalist.length>0){
               var dataListObjArr=[];
               for(var i=0;i<str.datalist.length;i++){
                   var dataListObj={};
                   dataListObj.partNumber=str.datalist[i].partNumber;
                   dataListObj.partName=str.datalist[i].partName;
                   //dataListObj.viewName=str.datalist[i].viewName;
                   dataListObj.partDescription=str.datalist[i].partDescription;
                   dataListObj.specialMonitor=str.datalist[i].specialMonitor;
                   dataListObj.whetherPartRecognize=str.datalist[i].whetherPartRecognize;
                   dataListObj.partSupplier=str.datalist[i].partSupplier;
                   dataListObj.partSupplier1=str.datalist[i].partSupplier;
                   dataListObjArr.push(dataListObj);
               }
               //window.path=str.path;
               renderTable(dataListObjArr);
           }else{
              /* alert("当前视图下不存在符合条件的数据")
               window.location.href="about:blank";
               window.opener=null;
               window.open('','_self');
               window.close();message*/
               var msg=str.message!=""&&str.message!=undefined?str.message:"您查询的数据不存在！";
               layerFn(msg,function(){
                   window.location.href="about:blank";
                   window.opener=null;
                   window.open('','_self');
                   window.close();
               });
           }
       }
   }

    function renderTable(dataListObjArr){
        //var json1 =dataListObjArr;
       // var nameList1= ["序号","物料编号","物料名称","物料描述","是否专显","是否已经样品承认","供应商"] //table的列名
       // widthList1 = ['0',"100","100","400","100","100","100"]//table每列的宽度
        window.historyList1=dataListObjArr;
        window.headers1=["序号","物料编号","物料名称","物料描述","是否专显","是否已经样品承认","供应商"]; //table的列名
        window.widths1= ['100',"100","200","300","100","100","100"];
        $(".formContent").empty().load('./newTable.html',"",function(){
            setTimeout(function(){
                var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;

                if($(".formContent")[0].offsetHeight>(heightform*0.85)){
                    $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
                }else{
                    $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
                }
                $("#pageBar2").css("display","block")
                $(".formContent").css({
                    "max-height":heightform*0.85,
                    "overflow-y":"scroll"
                });
                clearTimeout();
            },200)

        });

        $('.searchSureBtn').click(function(){
            var flag=getQueryStringByNameTwo("isRawMaterial")
            if(flag!=undefined&&flag=="true"){
                var url = "/sqe/sqeMaterialExcel",
                        data="view="+view+"&number="+encodeURIComponent(num);
                $("#loading").css({
                    display:"block"
                });
                MaterialReverseAjax(url,data,function(str){
                    $("#loading").css({
                        display:"none"
                    });
                    if(str.status!=undefined&&str.status=="success"){
                        if(str.path!=undefined&&str.path!=""){
                            window.open(str.path);
                        }

                    }else{
                        var mesg=str.message!=undefined&&str.message!=""?str.message:"系统异常稍后重试"
                        layerFn(mesg);
                    }
                });
            }else{
                var url='/sqe/sqeExportExcel';
                var datax=window.sqeExportExceldata;
                MaterialReverseAjax(url,datax,function(str){
                    if(str.status!=undefined&&str.status=="success"){
                        if(str.path!=undefined&&str.path!=""){
                            window.open(str.path);
                        }

                    }else{
                        var mesg=str.message!=undefined&&str.message!=""?str.message:"系统异常稍后重试"
                        layerFn(mesg);
                    }
                });
            }
        })
    }
    $(".formContent").scroll(function() {
        var scrolltop=$(this).scrollTop();
        if(scrolltop>0){
            $("#table2 table thead").css({
                "position":"absolute",
                "background":"#f2f2f2",
                "opacity":"1",
                "z-index": 999,
                "top":"46px"
            })
        }else{
            $("#table2 table thead").css({
                "position":""

            })
        }
        for (var i = 0; i <  window.widths1.length; i++) {
            var width = $("#table2 table tbody tr:first-child td").eq(i).width();
            if(IEVersion()>0){
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width-0.5
                })
            }else{
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width+1
                })
            }



            }

    })
    $(window).resize(function () { //当浏览器大小变化时
        //console.log($("#table2 table").width())
        $("#table2 table thead tr").css({
            "width":$("#table2 table").width()

        })
        var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;
        $(".formContent").css({
            "max-height":heightform*0.85,
            "overflow-y":"scroll"
        });
        if($(".formContent")[0].offsetHeight>(heightform*0.85)){
            $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
        }else{
            $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
        }
        for (var i = 0; i <  widthList1.length; i++) {
            var width = $("#table2 table tbody tr:first-child td").eq(i).width();
            if(IEVersion()>0){
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width-0.5
                })
            }else{
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width+1
                })
            }

        }
    });
</script>

</html>